import {createSlice} from '@reduxjs/toolkit'

const userSlice = createSlice({
    name: 'user',
    initialState:{
        id: null,
        name: '',
        email: '',
        role: ''
    },
    reducers:{
        setUser(state, {payload}){
            state.id = payload.id
            state.name = payload.name
            state.email = payload.email
            state.role = payload.role
        }
    }
})

export default userSlice.reducer
export const {setUser} = userSlice.actions